﻿using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace com.szmxsoft.yeming
{
	// Token: 0x02000004 RID: 4
	public class Encrypt
	{
		// Token: 0x06000003 RID: 3 RVA: 0x0000236C File Offset: 0x0000056C
		public static string Encrypt3Des(string str)
		{
			if (Utils.checkStr(str))
			{
				return "";
			}
			TripleDESCryptoServiceProvider tripleDESCryptoServiceProvider = new TripleDESCryptoServiceProvider();
			tripleDESCryptoServiceProvider.Key = Convert.FromBase64String("5tpMC2dovLDHzt/pRr/TOGSJPXANLG51");
			tripleDESCryptoServiceProvider.Mode = CipherMode.ECB;
			byte[] bytes = Encoding.Unicode.GetBytes(str);
			ICryptoTransform transform = tripleDESCryptoServiceProvider.CreateEncryptor();
			MemoryStream memoryStream = new MemoryStream();
			CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write);
			cryptoStream.Write(bytes, 0, bytes.Length);
			cryptoStream.FlushFinalBlock();
			byte[] inArray = memoryStream.ToArray();
			cryptoStream.Close();
			return Convert.ToBase64String(inArray);
		}

		// Token: 0x06000004 RID: 4 RVA: 0x000023F0 File Offset: 0x000005F0
		public static string Decrypt3Des(string str)
		{
			if (Utils.checkStr(str))
			{
				return "";
			}
			TripleDESCryptoServiceProvider tripleDESCryptoServiceProvider = new TripleDESCryptoServiceProvider();
			tripleDESCryptoServiceProvider.Key = Convert.FromBase64String("5tpMC2dovLDHzt/pRr/TOGSJPXANLG51");
			tripleDESCryptoServiceProvider.Mode = CipherMode.ECB;
			byte[] array = Convert.FromBase64String(str);
			ICryptoTransform transform = tripleDESCryptoServiceProvider.CreateDecryptor();
			MemoryStream memoryStream = new MemoryStream();
			CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write);
			cryptoStream.Write(array, 0, array.Length);
			cryptoStream.FlushFinalBlock();
			byte[] bytes = memoryStream.ToArray();
			cryptoStream.Close();
			return Encoding.Unicode.GetString(bytes);
		}

		// Token: 0x06000005 RID: 5 RVA: 0x00002474 File Offset: 0x00000674
		public static string EncryptDes(string pToEncrypt, string sKey)
		{
			DESCryptoServiceProvider descryptoServiceProvider = new DESCryptoServiceProvider();
			byte[] bytes = Encoding.Default.GetBytes(pToEncrypt);
			descryptoServiceProvider.Key = Encoding.ASCII.GetBytes(sKey);
			descryptoServiceProvider.IV = Encoding.ASCII.GetBytes(sKey);
			MemoryStream memoryStream = new MemoryStream();
			CryptoStream cryptoStream = new CryptoStream(memoryStream, descryptoServiceProvider.CreateEncryptor(), CryptoStreamMode.Write);
			cryptoStream.Write(bytes, 0, bytes.Length);
			cryptoStream.FlushFinalBlock();
			StringBuilder stringBuilder = new StringBuilder();
			foreach (byte b in memoryStream.ToArray())
			{
				stringBuilder.AppendFormat("{0:X2}", b);
			}
			stringBuilder.ToString();
			return stringBuilder.ToString();
		}

		// Token: 0x06000006 RID: 6 RVA: 0x00002528 File Offset: 0x00000728
		public static string DecryptDes(string pToDecrypt, string sKey)
		{
			DESCryptoServiceProvider descryptoServiceProvider = new DESCryptoServiceProvider();
			byte[] array = new byte[pToDecrypt.Length / 2];
			for (int i = 0; i < pToDecrypt.Length / 2; i++)
			{
				int num = Convert.ToInt32(pToDecrypt.Substring(i * 2, 2), 16);
				array[i] = (byte)num;
			}
			descryptoServiceProvider.Key = Encoding.ASCII.GetBytes(sKey);
			descryptoServiceProvider.IV = Encoding.ASCII.GetBytes(sKey);
			MemoryStream memoryStream = new MemoryStream();
			CryptoStream cryptoStream = new CryptoStream(memoryStream, descryptoServiceProvider.CreateDecryptor(), CryptoStreamMode.Write);
			cryptoStream.Write(array, 0, array.Length);
			cryptoStream.FlushFinalBlock();
			new StringBuilder();
			return Encoding.Default.GetString(memoryStream.ToArray());
		}

		// Token: 0x06000007 RID: 7 RVA: 0x000025D8 File Offset: 0x000007D8
		public static string MD5(string str)
		{
			MD5 md = new MD5CryptoServiceProvider();
			return BitConverter.ToString(md.ComputeHash(Encoding.Default.GetBytes(str))).Replace("-", "");
		}
	}
}
